<template>
  <div class="dashboard-container">
    <div class="dashboard-text">
      <span>{{ getTimeState }} &nbsp;&nbsp; {{ name }}</span>
    </div>
  </div>
</template>

<script>
import { mapGetters } from 'vuex';
import { reqQueryResumeById } from '@/views/Custom/ResumeMng/api/ResumeMngApi';
export default {
  name: 'Dashboard',
  computed: {
    ...mapGetters(['name', 'description', 'loginId']),
    getTimeState() {
      // 获取当前时间
      let timeNow = new Date();
      // 获取当前小时
      let hours = timeNow.getHours();
      // 设置默认文字
      let state = ``;
      // 判断当前时间段
      if (hours >= 0 && hours <= 10) {
        state = `🌞 早上好!`;
      } else if (hours > 10 && hours <= 11) {
        state = `🌞 上午好!`;
      } else if (hours > 11 && hours <= 13) {
        state = `🌼 中午好!`;
      } else if (hours > 13 && hours <= 18) {
        state = `🌼 下午好!`;
      } else if (hours > 18 && hours <= 24) {
        state = `😴 晚上好!`;
      }
      return state;
    },
  },
  mounted() {
    switch (this.description) {
      case '学生用户':
        // 检测简历是否编辑
        this.checkEidtResume();
        break;
    }
  },
  methods: {
    // 检测简历是否编辑
    checkEidtResume() {
      // 编辑简历
      reqQueryResumeById(this.loginId).then((res) => {
        if (res.data.flag) {
          this.$confirm(res.message, '提示', {
            confirmButtonText: '确定',
            cancelButtonText: '取消',
            type: 'warning',
          })
            .then(() => {
              this.$router.push({
                name: 'resumeEdit',
              });
            })
            .catch(() => {});
        }
      });
    },
  },
};
</script>

<style lang="scss" scoped>
.dashboard {
  &-container {
    margin: 30px;
    text-align: center;
  }
  &-text {
    // transform: translateY(50%);
    font-size: 30px;
    line-height: 46px;

    & span {
      font-family: Microsoft-YH;
    }
  }
}
</style>
